﻿using System;
using System.Windows.Forms;
using System.Media;
using Resources;
using System.Threading;
using TorchlightModOverseer.Views;
using TorchlightModOverseer.Domain.Models;
using TorchlightModOverseer.Commands;

namespace TorchlightModOverseer
{
	public partial class ConfigView : ViewBase
	{
		public ConfigView()
		{
			InitializeComponent();
		}

		public override void BindModel(object model)
		{
			BindModel(model as ConfigModel);
		}

		public void BindModel(ConfigModel model)
		{

			//ModFolder.Text = model.ModFolder;
			//TorchlightFolder.Text = model.TorchlightFolder;
		}

		public ConfigModel UpdateFromview()
		{
			return new ConfigModel
			{
				ModFolder = ModFolder.Text,
				TorchlightFolder = TorchlightFolder.Text
			};
		}

		private void ConfigView_Load(object sender, EventArgs e)
		{
			Subhheader.Message = @"I need to know where your 
mods and Torchlight install are!";

			ResourceManager.Current.HealDrinkSound.Play();
		}

		private void Ok_Click(object sender, EventArgs e)
		{
			Execute(new SaveConfigCommand(UpdateFromview()));
		}

		private void BrowseModFolder_Click(object sender, EventArgs e)
		{
			if (ModFolderBrowser.ShowDialog() == DialogResult.OK)
			{
				ModFolder.Text = ModFolderBrowser.SelectedPath;
			}
		}

		private void BrowseTorchlightFolder_Click(object sender, EventArgs e)
		{
			if (TorchlightFolderBrowser.ShowDialog() == DialogResult.OK)
			{
				TorchlightFolder.Text = TorchlightFolderBrowser.SelectedPath;
			}
		}

		private void ConfigView_Click(object sender, EventArgs e)
		{

		}
	}
}
